import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:args/args.dart';

void main(List<String> arguments) async {
  var commit = CommitCommand();

  var runner = CommandRunner('dgit', 'dgit description');
  runner.addCommand(commit);
  runner.argParser.addFlag(
    'name',
    negatable: false,
    abbr: 'n',
    callback: (v) => print('-n:$v'),
  );

  await runner.run(arguments).catchError((e) {
    if (e is! UsageException) throw e;
    print(e);
    exit(64); // Exit code 64 indicates a usage error.
  });

  // print(runner.usage);
  // print(runner.invocation);
}

class CommitCommand extends Command {
  @override
  String get description => 'commit desc';

  @override
  String get name => 'commit';

  CommitCommand() {
    argParser.addFlag('eeee', abbr: 'e', callback: (v) => print('-e:$v'));
  }
}

class StateCommand extends Command {
  @override
  String get description => 'state desc';

  @override
  String get name => 'state';

  StateCommand() {
    argParser.addFlag('rrrr', abbr: 'r');
  }
}
